class Emitter2 {
  constructor() {
    this.name = {};
  }
  on(key, handler) {
    if (!this.name[key]) {
      this.name[key] = [];
    }
    this.name[key].push(handler);
    return this;
  }
  emit(key, data) {
    if (this.name[key]) {
      this.name[key].forEach((handler) => handler(data));
    }
  }
}

export default Emitter2;


